package com.wxc.common;

import java.io.Serializable;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * @author wxc
 * @date 2021年10月01日 16:51
 */

public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    private String userName;
    private String password;
    private AtomicBoolean loginStatus = new AtomicBoolean(false);

    public User() {
    }

    public User(String userName, String password) {
        this.userName = userName;
        this.password = password;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public boolean getLoginStatus() {
        return loginStatus.get();
    }

    public void setLoginStatus(boolean status) {
        if(getLoginStatus() == status) return;
        while(true) {
            if(this.loginStatus.compareAndSet(this.loginStatus.get(),status)) break;
        }
    }

    @Override
    public String toString() {
        return "User{" +
                "userName='" + userName + '\'' +
                ", loginStatus=" + loginStatus.get() +
                '}';
    }
}
